home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / mig / dist / string.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-02-06  |  2.6 KB  |  106 lines

  1. /* 
  2.  * Mach Operating System
  3.  * Copyright (c) 1991,1990 Carnegie Mellon University
  4.  * All Rights Reserved.
  5.  * 
  6.  * Permission to use, copy, modify and distribute this software and its
  7.  * documentation is hereby granted, provided that both the copyright
  8.  * notice and this permission notice appear in all copies of the
  9.  * software, derivative works or modified versions, and any portions
  10.  * thereof, and that both notices appear in supporting documentation.
  11.  * 
  12.  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS 
  13.  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
  14.  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  15.  * 
  16.  * Carnegie Mellon requests users of this software to return to
  17.  * 
  18.  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
  19.  *  School of Computer Science
  20.  *  Carnegie Mellon University
  21.  *  Pittsburgh PA 15213-3890
  22.  * 
  23.  * any improvements or extensions that they make and grant Carnegie the
  24.  * rights to redistribute these changes.
  25.  */
  26. /*
  27.  * HISTORY
  28.  * $Log:    string.c,v $
  29.  * Revision 2.3  91/02/05  17:55:52  mrt
  30.  *     Changed to new Mach copyright
  31.  *     [91/02/01  17:55:57  mrt]
  32.  * 
  33.  * Revision 2.2  90/06/02  15:05:46  rpd
  34.  *     Created for new IPC.
  35.  *     [90/03/26  21:13:46  rpd]
  36.  * 
  37.  * 07-Apr-89  Richard Draves (rpd) at Carnegie-Mellon University
  38.  *    Extensive revamping.  Added polymorphic arguments.
  39.  *    Allow multiple variable-sized inline arguments in messages.
  40.  *
  41.  * 15-Jun-87  David Black (dlb) at Carnegie-Mellon University
  42.  *    Declare and initialize charNULL here for strNull def in string.h
  43.  *
  44.  * 27-May-87  Richard Draves (rpd) at Carnegie-Mellon University
  45.  *    Created.
  46.  */
  47.  
  48. #define    EXPORT_BOOLEAN
  49. #include <mach/boolean.h>
  50. #include <sys/types.h>
  51. #include "error.h"
  52. #include "alloc.h"
  53. #include "string.h"
  54.  
  55. string_t
  56. strmake(string)
  57.     char *string;
  58. {
  59.     register string_t saved;
  60.  
  61.     saved = malloc((u_int) (strlen(string) + 1));
  62.     if (saved == strNULL)
  63.     fatal("strmake('%s'): %s", string, unix_error_string(errno));
  64.     return strcpy(saved, string);
  65. }
  66.  
  67. string_t
  68. strconcat(left, right)
  69.     string_t left, right;
  70. {
  71.     register string_t saved;
  72.  
  73.     saved = malloc((u_int) (strlen(left) + strlen(right) + 1));
  74.     if (saved == strNULL)
  75.     fatal("strconcat('%s', '%s'): %s",
  76.           left, right, unix_error_string(errno));
  77.     return strcat(strcpy(saved, left), right);
  78. }
  79.  
  80. void
  81. strfree(string)
  82.     string_t string;
  83. {
  84.     free(string);
  85. }
  86.  
  87. char *
  88. strbool(bool)
  89.     boolean_t bool;
  90. {
  91.     if (bool)
  92.     return "TRUE";
  93.     else
  94.     return "FALSE";
  95. }
  96.  
  97. char *
  98. strstring(string)
  99.     string_t string;
  100. {
  101.     if (string == strNULL)
  102.     return "NULL";
  103.     else
  104.     return string;
  105. }
  106.